#include "mylabel.h"

myLabel::myLabel(QWidget* parent):QLabel(parent)
{

}

void myLabel::mousePressEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)qDebug()<<"按下左键";
    else if(event->button()==Qt::RightButton)qDebug()<<"按下右键";
    //以控件左上角为原点
    qDebug()<<event->x()<<' '<<event->y();
    //以屏幕左上角为原点
    qDebug()<<event->globalX()<<' '<<event->globalY();
}

void myLabel::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)qDebug()<<"左键释放";
    else if(event->button()==Qt::RightButton)qDebug()<<"右键释放";
}

void myLabel::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)qDebug()<<"双击左键";
    else if(event->button()==Qt::RightButton)qDebug()<<"双击右键";
}
